<?php

/**
 * TbsCliente form base class.
 *
 * @method TbsCliente getObject() Returns the current form's model object
 *
 * @package    AltargetEcommerce
 * @subpackage form
 * @author     Carlo Lopez
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseTbsClienteForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'cli_codigo'        => new sfWidgetFormInputHidden(),
      'cli_nombre'        => new sfWidgetFormInputText(),
      'cli_rif'           => new sfWidgetFormInputText(),
      'cli_codpais'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('fk_cli_codpais'), 'add_empty' => false)),
      'cli_codsec'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('fk_cli_codsec'), 'add_empty' => true)),
      'cli_email_address' => new sfWidgetFormInputText(),
      'cli_fecha_corte'   => new sfWidgetFormDate(),
      'cli_correorebo'    => new sfWidgetFormInputText(),
      'cli_franquicia'    => new sfWidgetFormInputCheckbox(),
      'cli_status'        => new sfWidgetFormInputText(),
      'cli_nit'           => new sfWidgetFormInputText(),
      'cli_pw'            => new sfWidgetFormInputText(),
      'cli_codseal'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('fk_cli_codseal'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'cli_codigo'        => new sfValidatorChoice(array('choices' => array($this->getObject()->get('cli_codigo')), 'empty_value' => $this->getObject()->get('cli_codigo'), 'required' => false)),
      'cli_nombre'        => new sfValidatorString(array('max_length' => 100)),
      'cli_rif'           => new sfValidatorString(array('max_length' => 30, 'required' => false)),
      'cli_codpais'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('fk_cli_codpais'))),
      'cli_codsec'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('fk_cli_codsec'), 'required' => false)),
      'cli_email_address' => new sfValidatorString(array('max_length' => 100)),
      'cli_fecha_corte'   => new sfValidatorDate(),
      'cli_correorebo'    => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'cli_franquicia'    => new sfValidatorBoolean(array('required' => false)),
      'cli_status'        => new sfValidatorString(array('max_length' => 1)),
      'cli_nit'           => new sfValidatorString(array('max_length' => 30, 'required' => false)),
      'cli_pw'            => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'cli_codseal'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('fk_cli_codseal'))),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'TbsCliente', 'column' => array('cli_email_address')))
    );

    $this->widgetSchema->setNameFormat('tbs_cliente[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'TbsCliente';
  }

}
